
capture log using replication.txt, replace

version 12
set matsize 3000
set seed 123456789

//instaling programs
ssc install xtpqml
ssc install center
* need to install ols_spatial_HAC from Sol Hsiang which can be found in the program folder//
* need to install reg2hdfespatial  which can be found in the program folder**


//Creating final data for district level analysis//


use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_basedta.dta", clear

//Creating Groundwater shock variables//

mkspline devabove0 0 devbelow0 =dif_ann_depth
replace devbelow0=devbelow0
replace devabove0=-devabove0


//Creating interaction of 2001 census variables and year dummies//
gen int_pop_01= tot_p if year==2001
gen int_pop_02= tot_p if year==2002
gen int_pop_03= tot_p if year==2003
gen int_pop_04= tot_p if year==2004
gen int_pop_05= tot_p if year==2005
gen int_pop_06= tot_p if year==2006
gen int_pop_07= tot_p if year==2007

gen int_percent_lit_01= percent_lit if year==2001
gen int_percent_lit_02= percent_lit if year==2002
gen int_percent_lit_03= percent_lit if year==2003
gen int_percent_lit_04= percent_lit if year==2004
gen int_percent_lit_05= percent_lit if year==2005
gen int_percent_lit_06= percent_lit if year==2006
gen int_percent_lit_07= percent_lit if year==2007

gen int_percent_work_01= percent_work if year==2001
gen int_percent_work_02= percent_work if year==2002
gen int_percent_work_03= percent_work if year==2003
gen int_percent_work_04= percent_work if year==2004
gen int_percent_work_05= percent_work if year==2005
gen int_percent_work_06= percent_work if year==2006
gen int_percent_work_07= percent_work if year==2007

gen int_percent_sc_01= percent_sc if year==2001
gen int_percent_sc_02= percent_sc if year==2002
gen int_percent_sc_03= percent_sc if year==2003
gen int_percent_sc_04= percent_sc if year==2004
gen int_percent_sc_05= percent_sc if year==2005
gen int_percent_sc_06= percent_sc if year==2006
gen int_percent_sc_07= percent_sc if year==2007

gen int_percent_female_01= percent_female if year==2001
gen int_percent_female_02= percent_female if year==2002
gen int_percent_female_03= percent_female if year==2003
gen int_percent_female_04= percent_female if year==2004
gen int_percent_female_05= percent_female if year==2005
gen int_percent_female_06= percent_female if year==2006
gen int_percent_female_07= percent_female if year==2007

gen int_percent_fm_ratio_01= fm_ratio if year==2001
gen int_percent_fm_ratio_02= fm_ratio if year==2002
gen int_percent_fm_ratio_03= fm_ratio if year==2003
gen int_percent_fm_ratio_04= fm_ratio if year==2004
gen int_percent_fm_ratio_05= fm_ratio if year==2005
gen int_percent_fm_ratio_06= fm_ratio if year==2006
gen int_percent_fm_ratio_07= fm_ratio if year==2007

for var int_*:replace X=0 if X==.
tab year, gen(dumyr)

save "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta", replace

****************************************************************
* Table 1: summary stats *
****************************************************************

use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"


local stats "Mean Min Max SD"
local sumvars " ann_depth rainmean total_rape total_cr_women total_crimes"
* calculate summary stats by year:
foreach i of local sumvars {
	foreach j of local stats {
		preserve
		local k = lower("`j'")
		collapse (`k') `i', by(year)
		gen var = "`i'"
		qui: reshape wide `i', i(var) j(year)
		gen stat = "`j'"
		rename `i'* v*
		qui: save `i'`j', replace
		restore
	}
}

* calculate overall summary stats:
foreach j of local stats {
	preserve
	local k = lower("`j'")
	collapse (`k') ann_depth rainmean total_rape total_cr_women total_crimes
	rename * overall*
	gen stat = "`j'"
	qui: reshape long overall, i(stat) j(var) string
	qui: save overall`j', replace
	restore
}

* combine stats into one table:
clear
foreach i of local sumvars {
	foreach j of local stats {
		append using `i'`j'
		erase  `i'`j'.dta
	}
}
save table1, replace

* add overall summary stats:
clear
foreach j of local stats {
	append using overall`j'
	erase  overall`j'.dta
}
merge 1:1 var stat using table1
drop _merge 
order var stat v* overall
encode stat, gen(statnum)
encode var, gen(varnum)
recode statnum (2=1) (3=2) (1=3)
recode varnum (2=4) (3=5) (4=3) (5=2)

foreach i of varlist v2002-v2007 overall {
	replace `i' = round(`i') if var=="total_cr_women" | var=="total_crimes"  | (var=="total_rape" & stat~="Mean")
	replace `i' = round(`i',0.1) if var=="total_rape" & stat=="Mean"
	replace `i' = round(`i',0.01) if var=="rainmean"| var=="ann_depth"
}
expand 2 if varnum==1 & statnum==1
sort varnum statnum
drop varnum statnum
replace var = "Annual Depth" if var=="ann_depth"
replace var = "Average Rainfall" if var=="rainmean"
replace var = "Total Rapes" if var=="total_rape"
replace var = "Crimes against women" if var=="total_cr_women"
replace var = "Total Crimes" if var=="total_crimes"


replace stat = "Statistic" if _n==1
replace overall = -99 if _n==1
lab def tmp1 -99 "Overall" 
lab val overall tmp1
replace var = "" if mod(_n,4)~=2
replace var = "Variable" if _n==1

gen finalorder = _n
expand 2 if mod(_n,4)==1
foreach i of varlist v2002-v2007 overall {
	replace `i' = . if _n>21
}
foreach i of varlist var-stat {
	replace `i' = "" if _n>21
}
replace finalorder = finalorder + 0.1 if _n>21

sort finalorder
replace var = "Depth" if var[_n-1]=="Annual Depth"
replace var = "Annual" if var[_n]=="Annual Depth"
replace var = "Rainfall" if var[_n-1]=="Average Rainfall"
replace var = "Average" if var=="Average Rainfall"
replace var = "meters/" if _n==5
replace var = "year" if _n==6
replace var = "Rapes" if var[_n-1]=="Total Rapes"
replace var = "Total" if var=="Total Rapes"
replace var = "women" if var[_n-2]=="Crimes against women"
replace var = "against" if var[_n-1]=="Crimes against women"
replace var = "Crimes" if var=="Crimes against women"
replace var = "Crimes" if var[_n-1]=="Total Crimes"
replace var = "Total" if var[_n]=="Total Crimes"

forvalues i = 2002(1)2007 {
	replace v`i' = `i' if _n==1
}

expand 2 if _n==_N
replace var = "Observations" if _n==_N
replace overall = 3186 if _n==_N
recode v2002-v2007 (.=531) if _n==_N

texsave var stat v2002-v2007 overall using table1, align(llrrrrrrr) frag nonames replace
save table1, replace
outsheet var stat v2002-v2007 overall using table1.csv, replace comma nonames


****************************************************************
* Table 2: summary stats Of IHDS
****************************************************************


use  "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\master_data_final.dta", clear

bys year: sum wellwater walk_tm_water time_water_women time_water_men male female agri_wage_female nonagri_wage_female consumption_pc below_pov_line kisan_credit motorcycle mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned  



****************************************************************
* Table 3: Estimates of Water Scarcity on Rapes: Quasi-Maximum Likelihood Estimation *
****************************************************************


set matsize 10000
set seed 123456789

ssc install xtpqml
ssc install center

**xtpqml Regression*******
use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"
capture erase tabmainresults2.txt
capture erase tabmainresults2.tex

* no controls
xi:xtpqml total_rape devbelow0 devabove0 dumyr*,fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmainresults2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

* add Demographic controls (baseline)
xi:xtpqml total_rape devbelow0 devabove0 dumyr* int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07, fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmainresults2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, -) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)


xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07, fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmainresults2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

* Annual Temperature
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 ann_t, fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmainresults2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier ann_t) addtext(Demographic controls, Yes, Other controls, Annual Temperature) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)


* baseline with Night light
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 nlight_avg, fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=. & nlight_avg!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmainresults2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Night Light) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

** district specific time trend
* baseline with district trends (use xtpoisson b/c clustered errors can't be calculated; note no Demographic controls)
egen idcode=group(id)
quietly tab idcode,gen(idcode_dum)
quietly for num 1/531: replace idcode_dumX = idcode_dumX*(year-2001)

xtpoisson total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq idcode_dum* , fe
qui summ total_rape if devbelow0!=. & devabove0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmainresults2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, District specific trends) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

drop idcode_dum*





* drop big cities
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 if dum_bigcity==0, fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=. & dum_bigcity==0
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmainresults2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Exclude big cities) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean) tex(frag)
 
 capture erase tabmainresults.tex
filefilter tabmainresults2.tex tabmainresults3.tex, from("Annual Rainfall") to("\BSvtop{\BShbox{\BSstrut Annual}\BShbox{\BSstrut Rainfall}}") replace
filefilter tabmainresults3.tex tabmainresults4.tex, from("District specific trends") to("\BSvtop{\BShbox{\BSstrut District}\BShbox{\BSstrut specific}\BShbox{\BSstrut trends}}") replace
filefilter tabmainresults4.tex tabmainresults5.tex, from("Number of id") to("Districts") replace
filefilter tabmainresults5.tex tabmainresults6.tex, from("VARIABLES") to("") replace
filefilter tabmainresults6.tex tabmainresults7.tex, from("Exclude big cities") to("\BSvtop{\BShbox{\BSstrut Exclude}\BShbox{\BSstrut big}\BShbox{\BSstrut cities}}") replace
filefilter tabmainresults7.tex tabmainresults8.tex, from("Annual Temperature") to("\BSvtop{\BShbox{\BSstrut Annual}\BShbox{\BSstrut Temperature}\BShbox{\BSstrut }}") replace

filefilter tabmainresults8.tex tabmainresults.tex, from("Night Light") to("\BSvtop{\BShbox{\BSstrut Night}\BShbox{\BSstrut Light}}") replace

forvalues i = 2(1)8 {
	erase tabmainresults`i'.tex
}


*****************************************************************************************************
* Table 4: Effect of Groundwater Depth Shocks on Rapes by Timing of Shocks *
******************************************************************************************************

use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"
xtset id year
capture erase tabtiminglagsleads2.txt
capture erase tabtiminglagsleads2.tex

for var devbelow0 devabove0: gen lead_X=F.X
for var devbelow0 devabove0: gen lag_X=L.X
* no controls
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq if year>=2003 & lag_devbelow0!=.,fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=. & lag_devbelow0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabtiminglagsleads2.tex, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* ) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

*Including Lags
xi:xtpqml total_rape devbelow0 devabove0 lag_devbelow0 lag_devabove0 dumyr* raindev1 raindevsq,fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=. & lag_devbelow0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabtiminglagsleads2.tex, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* ) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

*includong Leads
xi:xtpqml total_rape devbelow0 devabove0 lead_devabove0 lead_devbelow0 dumyr* raindev1 raindevsq,fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=. & lag_devbelow0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabtiminglagsleads2.tex, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* ) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)




 capture erase tabtiminglagsleads.tex
 
 
 *****************************************************************************************************
* Table 5: Effect of Groundwater Depth Shocks on Time to Collect Water*
******************************************************************************************************

use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\master_data_final.dta", clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

areg  lnwalk_tm_water  devbelow0 devabove0  i.year, absorb(id) robust
qui summ walk_tm_water
scalar mean=`r(mean)'
outreg2 using "walk_time_water.tex", replace br label nocons nonotes eq(auto) ctitle(" ") drop(raindev1 raindevsq ) addtext(Controls, no) addstat("Mean of the dependent variable (in level)", mean)
areg  lnwalk_tm_water  devbelow0 devabove0 raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned i.year, absorb(id) robust
qui summ walk_tm_water
scalar mean=`r(mean)'
outreg2 using "walk_time_water.tex", append br label nocons nonotes eq(auto) ctitle(" ") drop( consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_ownedraindev1 raindevsq ) addtext(Controls, yes) addstat("Mean of the dependent variable (in level)", mean)
areg  lnwalk_tm_water  devbelow0 devabove0  i.year raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned wellwater  , absorb(id) robust
qui summ walk_tm_water
scalar mean=`r(mean)'
outreg2 using "walk_time_water.tex", append br label nocons nonotes eq(auto) ctitle(" ") drop(consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned raindev1 raindevsq ) addtext(Controls, yes) addstat("Mean of the dependent variable (in level)", mean)
areg  lnwalk_tm_water  devbelow0 devabove0  i.year raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned wellwater devabove0_wellwater devbelow0_wellwater , absorb(id) robust
qui summ walk_tm_water
scalar mean=`r(mean)'
outreg2 using "walk_time_water.tex", append br label nocons nonotes eq(auto) ctitle(" ") drop(consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned raindev1 raindevsq ) addtext(Controls, yes) addstat("Mean of the dependent variable (in level)", mean)

*****************************************************************************************************
*Table 6: Estimates of Rape: District Women’s Exposure Due to Water Collection and Negative Shocks***
*******************************************************************************************************
use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\master_data_final.dta", clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

collapse (mean) rape dif_ann_depth lnwalk_tm_water female female_lnwalk_time wellwater  raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned (first) devbelow0 devabove0 int_percent_sc_05-int_percent_sc_12 int_percent_lit_05-int_percent_lit_12 int_percent_work_05-int_percent_work_12 int_pop_05-int_pop_12   , by(id year)
replace dif_ann_depth=0 if dif_ann_depth==.
gen z=female_lnwalk_time*female
areg  rape c.devbelow0#c.wellwater#c.z  c.z#c.devbelow0 c.z#c.wellwater c.devbelow0#c.wellwater z devbelow0 wellwater  i.year , absorb(id) robust
qui summ rape
scalar mean=`r(mean)'
outreg2 using "rape_negative_shocks1.xls", replace br label nocons  drop(att_pub_meeting  area_owned highest_adedu below_pov_line official_panchayet) addtext(Controls, no) addstat("Mean of the dependent variable", mean)
areg  rape c.devbelow0#c.wellwater#c.z  c.z#c.devbelow0 c.z#c.wellwater c.devbelow0#c.wellwater z devbelow0 wellwater i.year  int_percent_sc_05-int_percent_sc_12 int_percent_lit_05-int_percent_lit_12 int_percent_work_05-int_percent_work_12 int_pop_05-int_pop_12, absorb(id) robust
qui summ rape
scalar mean=`r(mean)'

outreg2 using "rape_negative_shocks1.xls", append br label nocons  drop(raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned) addtext(Controls, yes) addstat("Mean of the dependent variable", mean)





*****************************************************************************************************
* Table 7: Additional Robustness Tests for Rapes: Quasi-Maximum Likelihood Estimation*
******************************************************************************************************

use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File"
merge m:1 id using "census_2001.dta", keepusing(tot_work_p tot_work_m tot_work_f)
drop _merge
merge m:1 id using "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\unemployment_nsso_61st.dta"


gen rel_unemployment=male_unemployed/female_unemployed
gen rel_work_pop= tot_work_m/ tot_work_f


gen int_rel_work_02= rel_work_pop if year==2002
gen int_rel_work_03= rel_work_pop if year==2003
gen int_rel_work_04= rel_work_pop if year==2004
gen int_rel_work_05= rel_work_pop if year==2005
gen int_rel_work_06= rel_work_pop if year==2006
gen int_rel_work_07= rel_work_pop if year==2007
for var int_rel_work_02-int_rel_work_07: replace X=0 if X==.

gen rel_unemployment_02= rel_work_pop if year==2002
gen rel_unemployment_03= rel_work_pop if year==2003
gen rel_unemployment_04= rel_work_pop if year==2004
gen rel_unemployment_05= rel_work_pop if year==2005
gen rel_unemployment_06= rel_work_pop if year==2006
gen rel_unemployment_07= rel_work_pop if year==2007
for var rel_unemployment_02-rel_unemployment_07: replace X=0 if X==. 




cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

capture erase tabmaincontinued2.txt
capture erase tabmaincontinued2.tex


* baseline with murders
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 total_murder, fe cluster(id)
qui summ total_rape
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmaincontinued2.tex, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Murders) addstat("F stat", `r(chi2)', "Sig. level", `r(p)', "Mean of the dependent variable", mean)


*Rural Poverty Rate
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 inpov1_03-inpov1_07, fe cluster(id)
qui summ total_rape
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmaincontinued2.tex, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier inpov1*) addtext(Demographic controls, Yes, Other controls, Rural Poverty Rate) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

*Urban Poverty rate
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 inpov2_03-inpov2_07, fe cluster(id)
qui summ total_rape
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmaincontinued2.tex, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier inpov2*) addtext(Demographic controls, Yes, Other controls, Urban Poverty Rate) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)


*Rural Poverty Gap
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 povgap1_03-povgap1_07, fe cluster(id)
qui summ total_rape
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmaincontinued2.tex, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier povgap1*) addtext(Demographic controls, Yes, Other controls, Rural Poverty Gap) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

*Urban Poverty Gap
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 povgap2_03-povgap2_07, fe cluster(id)
qui summ total_rape
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmaincontinued2.tex, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier povgap2*) addtext(Demographic controls, Yes, Other controls, Urban Poverty Gap) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

*Rural Consumption Expenditure
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 logmean1_03-logmean1_07, fe cluster(id)
qui summ total_rape
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmaincontinued2.tex, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier logmean1*) addtext(Demographic controls, Yes, Other controls, Rural Consumption Expenditure) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

*Urban Consumption Expenditure
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 logmean2_03-logmean2_07, fe cluster(id)
qui summ total_rape
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmaincontinued2.tex, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier logmean2*) addtext(Demographic controls, Yes, Other controls, Urban Consumption Expenditure) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

/*
* baseline with relative working population
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07  int_rel_work_03-int_rel_work_07, fe cluster(id)
qui summ total_rape
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmaincontinued2.tex, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Male-Female Employment Ratio) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

*/


* baseline with relative unemployment
xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07  rel_unemployment_03-rel_unemployment_07, fe cluster(id)
qui summ total_rape
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using tabmaincontinued2.tex, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Male-Female Employment Ratio) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

 capture erase tabmaincontinued.tex
filefilter tabmaincontinued2.tex tabmaincontinued3.tex, from("Rural Poverty Rate") to("\BSvtop{\BShbox{\BSstrut Rural}\BShbox{\BSstrut Poverty}\BShbox{\BSstrut Rate}}") replace
filefilter tabmaincontinued3.tex tabmaincontinued4.tex, from("Urban Poverty Rate") to("\BSvtop{\BShbox{\BSstrut Urban}\BShbox{\BSstrut Poverty}\BShbox{\BSstrut Rate}}") replace
filefilter tabmaincontinued4.tex tabmaincontinued5.tex, from("Rural Poverty Gap ") to("\BSvtop{\BShbox{\BSstrut Rural}\BShbox{\BSstrut Poverty}\BShbox{\BSstrut Gap}}") replace
filefilter tabmaincontinued5.tex tabmaincontinued6.tex, from("Urban Poverty Gap") to("\BSvtop{\BShbox{\BSstrut Urban}\BShbox{\BSstrut Poverty}\BShbox{\BSstrut Gap}}") replace
filefilter tabmaincontinued6.tex tabmaincontinued7.tex, from("Rural Consumption Expenditure") to("\BSvtop{\BShbox{\BSstrut Rural}\BShbox{\BSstrut Consumption}\BShbox{\BSstrut Expenditure}}") replace
filefilter tabmaincontinued7.tex tabmaincontinued8.tex, from("Urban Consumption Expenditure") to("\BSvtop{\BShbox{\BSstrut Urban}\BShbox{\BSstrut Consumption}\BShbox{\BSstrut Expenditure}}") replace
filefilter tabmaincontinued8.tex tabmaincontinued9.tex, from("Number of id") to("Districts") replace
filefilter tabmaincontinued9.tex tabmaincontinued10.tex, from("Male-Female Unemployment Ratio") to("\BSvtop{\BShbox{\BSstrut Male-female}\BShbox{\BSstrut Employment}\BShbox{\BSstrut Ratio}}") replace

filefilter tabmaincontinued10.tex tabmaincontinued.tex, from("VARIABLES") to("") replace

forvalues i = 2(1)10 {
	erase tabmaincontinued`i'.tex
}

*****************************************************************************************************
* Table 8: Effect of Groundwater Depth Shocks on Rape: By NREGA*
******************************************************************************************************
use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd  "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File" 
merge m:1 id using  "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\nrega.dta"

cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"
gen post=(year>2005)
for var nrega_1st nrega_2nd nrega_3rd: replace X=0 if X==.
for var dif_ann_depth devabove0 devbelow0: gen X_post=X*post
for var dif_ann_depth devabove0 devbelow0: gen X_Nrega=X* nrega_1st
for var dif_ann_depth devabove0 devbelow0: gen X_Nrega_post=X* nrega_1st*post
gen nrega_post=nrega_1st*post
gen treatment=1 if nrega_1st==1 & year>=2006
replace treatment=1 if nrega_2nd==1 & year==2007
replace treatment=0 if treatment==.
for var dif_ann_depth devabove0 devbelow0: gen X_treatment=X*treatment

 
xi:xtpqml total_rape dif_ann_depth treatment dif_ann_depth_treatment dumyr* raindev1 raindevsq , fe cluster(id)
qui summ total_rape
scalar mean=`r(mean)'
outreg2 using "deviation_shock_nrega_rolling.tex", replace addstat("Mean of the dependent variable", mean)
xi:xtpqml total_rape dif_ann_depth treatment dif_ann_depth_treatment dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 , fe cluster(id)
qui summ total_rape
scalar mean=`r(mean)'
outreg2 using "deviation_shock_nrega_rolling.tex", append addstat("Mean of the dependent variable", mean)


*******************************************************************************************************************
********************************Appendix Tables and Figures *****************************************************
******************************************************************************************************************



********************************************************************************************
* Figure A2: Lowess regression of Groundwater Shocks on Rainfall Shocks *
******************************************************************************************
use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"
lowess dif_ann_depth raindev1, saving(c)
lowess lr_depth crumean, saving(d)

/// Net of District and Year Fixed Effects//
reg dif_ann_depth i.year 
predict  res_dif_ann_depth, res
reg raindev1 i.year i.id
predict  res_raindev1, res


lowess res_dif_ann_depth res_raindev1, saving(f)

*******************************************************************************************************
***Figure A3: Lowess regression of Groundwater Shocks on Rainfall Shocks in the Previous Year**********
********************************************************************************************************
use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"
xtset id year
gen l_raindev1=l.raindev1

/// Net of District and Year Fixed Effects//
reg dif_ann_depth i.year 
predict  res_dif_ann_depth, res
reg raindev1 i.year i.id
predict  res_raindev1, res


lowess res_dif_ann_depth l.res_raindev1, saving(h)





************************************************************************************************************
**Figure A4: Marginal Effect of the Negative Groundwater Shock on Rape
************************************************************************************************************
 use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\master_data_final.dta", clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

collapse (mean) rape lnwalk_tm_water female female_lnwalk_time wellwater  raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned (first) devbelow0 devabove0 int_percent_sc_05-int_percent_sc_12 int_percent_lit_05-int_percent_lit_12 int_percent_work_05-int_percent_work_12 int_pop_05-int_pop_12   , by(id year)

gen z=female_lnwalk_time*female


reg  rape z devbelow0 wellwater c.z#c.devbelow0 c.z#c.wellwater c.devbelow0#c.wellwater c.devbelow0#c.wellwater#c.z i.year i.id, robust

margins, dydx(devbelow0) at(z=(0(.1) 1))
marginsplot, yline(0) level(95) graphregion(color(white)) xtitle("District's female exposure to water collection ") ytitle("Predicted Rape") title("")


*****************************************************************************************************
* Table A1: Summary Statistics of Variation in Groundwater*
******************************************************************************************************
use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear

gen positive_shock= (devabove0>0)
gen negative_shock= ( devbelow0 >0)
for var positive_shock negative_shock: replace X=. if dif_ann_depth==0
for var positive_shock negative_shock: replace X=. if dif_ann_depth==.
table year, c(mean dif_ann_depth sd dif_ann_depth mean positive_shock mean negative_shock)


**************************************************************************************************************
************ Table A2: Summary Statistics of Groundwater Shocks***********************************************
**************************************************************************************************************


use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"


table year,c(mean devbelow0 sd devbelow0 mean devabove0 sd devabove0)
table year if devbelow!=0,c(mean devbelow0 sd devbelow0 )
table year if devabove0!=0,c(mean devabove0 sd devabove0 )
sum devbelow0 devabove0



*****************************************************************************************************
* Table A3: Effect of Groundwater Depth Shocks on Rape: Linear Regression*
******************************************************************************************************

use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

capture erase resultslin2.txt
capture erase resultslin2.tex

areg lnrape devbelow0 devabove0 dumyr*,absorb(id) cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultslin2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

areg lnrape devbelow0 devabove0 dumyr* int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07, absorb(id) cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultslin2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, -) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

areg lnrape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07, absorb(id) cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultslin2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

areg lnrape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 total_crimes, absorb(id) cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultslin2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Total crimes) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

areg lnrape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 total_cr_women, absorb(id) cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultslin2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Crimes against women) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

areg lnrape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 total_murder, absorb(id) cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultslin2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Murders) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

** district specific time trend
* baseline with district trends (use xtpoisson b/c clustered errors can't be calculated; note no Demographic controls)
egen idcode=group(id)
quietly tab idcode,gen(idcode_dum)
quietly for num 1/531: replace idcode_dumX = idcode_dumX*(year-2001)

areg lnrape devbelow0 devabove0 dumyr* raindev1 raindevsq idcode_dum* , absorb(id) cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=.
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultslin2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, District specific trends) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

drop idcode_dum*

areg lnrape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 if dum_bigcity==0, absorb(id) cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=. & dum_bigcity==0
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultslin2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Exclude big cities) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean) tex(frag)

capture erase resultslin.tex
filefilter resultslin2.tex resultslin3.tex, from("Crimes against women") to("\BSvtop{\BShbox{\BSstrut Crimes}\BShbox{\BSstrut against}\BShbox{\BSstrut women}}") replace
filefilter resultslin3.tex resultslin4.tex, from("Total crimes") to("\BSvtop{\BShbox{\BSstrut Total}\BShbox{\BSstrut crimes}}") replace
filefilter resultslin4.tex resultslin5.tex, from("Annual Rainfall") to("\BSvtop{\BShbox{\BSstrut Annual}\BShbox{\BSstrut Rainfall}}") replace
filefilter resultslin5.tex resultslin6.tex, from("District specific trends") to("\BSvtop{\BShbox{\BSstrut District}\BShbox{\BSstrut specific}\BShbox{\BSstrut trends}}") replace
filefilter resultslin6.tex resultslin7.tex, from("Number of id") to("Districts") replace
filefilter resultslin7.tex resultslin8.tex, from("VARIABLES") to("") replace
filefilter resultslin8.tex resultslin.tex, from("Exclude big cities") to("\BSvtop{\BShbox{\BSstrut Exclude}\BShbox{\BSstrut big}\BShbox{\BSstrut cities}}") replace
forvalues i = 2(1)8 {
	erase resultslin`i'.tex
}


*****************************************************************************************************
* Table A4: Effect of Groundwater Depth Shocks on Rape: Sensitivity to Different Specifications*
******************************************************************************************************
use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

xi:xtpqml total_rape devbelow0  dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07  int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07, fe cluster(id)
outreg2 using "rape_senstitivity.xls", replace br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall) 
xi:xtpqml total_rape dif_ann_depth  dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07  int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07, fe cluster(id)
outreg2 using "rape_senstitivity.xls", append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall)

gen dif_ann_depth_sq=dif_ann_depth^2
bys year :egen mean_dif_ann_depth=mean( dif_ann_depth)

xi:xtpqml total_rape dif_ann_depth dif_ann_depth_sq dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07  int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07, fe cluster(id)
outreg2 using "rape_senstitivity.xls", append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall)

areg lnrape dif_ann_depth dif_ann_depth_sq dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07  int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 , absorb(id) cluster(id)
outreg2 using "rape_senstitivity.xls", append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall)

bys year :egen sd_dif_ann_depth=sd( dif_ann_depth)
gen z_dif_ann_depth=(dif_ann_depth- mean_dif_ann_depth)/ sd_dif_ann_depth
bys year :egen mean_devbelow0=mean( devbelow0)
bys year :egen sd_devbelow0=sd( devbelow0)
gen z_devbelow0=(devbelow0- mean_devbelow0)/ sd_devbelow0
bys year :egen mean_devabove0=mean( devabove0)
bys year :egen sd_devabove0=sd( devabove0)
gen z_devabove0=(devabove0- mean_devabove0)/ sd_devabove0

xi:xtpqml total_rape z_dif_ann_depth  dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07  int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07, fe cluster(id)
outreg2 using "rape_senstitivity.xls", append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall)


xi:xtpqml total_rape z_devbelow0  dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07  int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07, fe cluster(id)
outreg2 using "rape_senstitivity.xls", append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall)
xi:xtpqml total_rape z_devbelow0 z_devabove0  dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07  int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07, fe cluster(id)
outreg2 using "rape_senstitivity.xls", append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall)

*xi:xtnbreg total_rape devbelow0 devabove0 i.year raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07  int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 , fe 
*outreg2 using "rape_senstitivity.xls", append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall)

/*xtset id year
gen growth_pop=exp((ln( tot_p_2011)-ln( tot_p) )/10)-1
gen imputed_pop= tot_p*(1+ growth_pop) if year==2002
replace imputed_pop= l.imputed_pop * (1+growth_pop) if imputed_pop==.
gen normalized_rape= (total_rape/imputed_pop)*1000000*/


xtset id year
gen growth_fpop=exp((ln( tot_f_2011)-ln( tot_f) )/10)-1
gen imputed_fpop= tot_f*(1+ growth_fpop) if year==2002
replace imputed_fpop= l.imputed_fpop * (1+growth_fpop) if imputed_fpop==.
gen normalized_rape_f= (total_rape/imputed_fpop)*100000

xi:xtpqml normalized_rape_f devbelow0 devabove0  dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07  int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07, fe cluster(id)
outreg2 using "rape_senstitivity.xls", append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall)

gen ln_normalized_rape_f=ln(1+normalized_rape_f)
areg ln_normalized_rape_f devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07  int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07, absorb(id) cluster(id)
outreg2 using "rape_senstitivity.xls", append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall)



*****************************************************************************************************
* Table A5:Effect of Groundwater Depth Shocks on Rape: Linear Regression with Conely Spatial Stan-dard Error *
******************************************************************************************************

use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

*ssc install tmpdir
*ssc install reg2hdfe

capture erase resultsconely2.txt
capture erase resultsconely2.tex

reg2hdfespatial lnrape devbelow0 devabove0 , timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(50)
qui summ total_rape if devbelow0!=. & devabove0!=. & latitude!=0
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)

outreg2 using resultsconely2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

reg2hdfespatial lnrape devbelow0 devabove0 int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 , timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(50)
qui summ total_rape if devbelow0!=. & devabove0!=. & latitude!=0
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultsconely2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, -) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

reg2hdfespatial lnrape devbelow0 devabove0 raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 , timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(50)
qui summ total_rape if devbelow0!=. & devabove0!=. & latitude!=0
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultsconely2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

reg2hdfespatial lnrape devbelow0 devabove0 raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 total_crimes, timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(50)
qui summ total_rape if devbelow0!=. & devabove0!=. & latitude!=0
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultsconely2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Total crimes) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

reg2hdfespatial lnrape devbelow0 devabove0 raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 total_cr_women , timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(50)
qui summ total_rape if devbelow0!=. & devabove0!=. & latitude!=0
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultsconely2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Crimes against women) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

reg2hdfespatial lnrape devbelow0 devabove0 raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 total_murder , timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(50)
qui summ total_rape if devbelow0!=. & devabove0!=. & latitude!=0
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultsconely2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Murders) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)


reg2hdfespatial lnrape devbelow0 devabove0 raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 if dum_bigcity==0 , timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(50)
qui summ total_rape if devbelow0!=. & devabove0!=. & latitude!=0 & dum_bigcity==0
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using resultsconely2.txt, br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, Exclude big cities) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean) tex(frag)

capture erase resultsconely.tex
filefilter resultsconely2.tex resultsconely3.tex, from("Crimes against women") to("\BSvtop{\BShbox{\BSstrut Crimes}\BShbox{\BSstrut against}\BShbox{\BSstrut women}}") replace
filefilter resultsconely3.tex resultsconely4.tex, from("Total crimes") to("\BSvtop{\BShbox{\BSstrut Total}\BShbox{\BSstrut crimes}}") replace
filefilter resultsconely4.tex resultsconely5.tex, from("Annual Rainfall") to("\BSvtop{\BShbox{\BSstrut Annual}\BShbox{\BSstrut Rainfall}}") replace
filefilter resultsconely5.tex resultsconely6.tex, from("Number of id") to("Districts") replace
filefilter resultsconely6.tex resultsconely7.tex, from("VARIABLES") to("") replace
filefilter resultsconely7.tex resultsconely.tex, from("Exclude big cities") to("\BSvtop{\BShbox{\BSstrut Exclude}\BShbox{\BSstrut big}\BShbox{\BSstrut cities}}") replace
forvalues i = 2(1)7 {
	erase resultsconely`i'.tex
}


*****************************************************************************************************
* Table A6:  Effect of Groundwater Depth Shocks on Rapes:  Sensitivity of Conely Spatial StandardError to Distance Cuto*
******************************************************************************************************

use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

ssc install tmpdir
ssc install reg2hdfe

reg2hdfespatial lnrape devbelow0 devabove0 raindev1 raindevsq ann_t int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 , timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(10)
test (devbelow0=0) (devabove0=0)
outreg2 using sensitivity2.tex, replace br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall) addstat("F stat", `r(F)', "Sig. level", `r(p)')

reg2hdfespatial lnrape devbelow0 devabove0 raindev1 raindevsq ann_t int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 , timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(50)
test (devbelow0=0) (devabove0=0)
outreg2 using sensitivity2.tex, append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall) addstat("F stat", `r(F)', "Sig. level", `r(p)')

reg2hdfespatial lnrape devbelow0 devabove0 raindev1 raindevsq ann_t int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 , timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(100)
test (devbelow0=0) (devabove0=0)
outreg2 using sensitivity2.tex, append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall) addstat("F stat", `r(F)', "Sig. level", `r(p)')

reg2hdfespatial lnrape devbelow0 devabove0 raindev1 raindevsq ann_t int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 , timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(500)
test (devbelow0=0) (devabove0=0)
outreg2 using sensitivity2.tex, append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall) addstat("F stat", `r(F)', "Sig. level", `r(p)')

reg2hdfespatial lnrape devbelow0 devabove0 raindev1 raindevsq ann_t int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 , timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(1000)
test (devbelow0=0) (devabove0=0)
outreg2 using sensitivity2.tex, append  br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall) addstat("F stat", `r(F)', "Sig. level", `r(p)')

reg2hdfespatial lnrape devbelow0 devabove0 raindev1 raindevsq ann_t int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 , timevar(year) panelvar(id) lat( latitude ) lon( longitude ) distcutoff(5000)
test (devbelow0=0) (devabove0=0)
outreg2 using sensitivity2.tex, append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier raindev1 raindevsq ) addtext(Demographic controls, Yes, Other controls, Rainfall) addstat("F stat", `r(F)', "Sig. level", `r(p)')


*****************************************************************************************************
* Table A7: Effect of Groundwater Depth Shocks on Gender-based Violence*
******************************************************************************************************


use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"
xtset id year
local crime_vars "total_molestation total_sex_harass total_dowry_deaths total_cruelty_by_husband"
xi:xtpqml total_rape devbelow0 devabove0  dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07  ,fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=. 
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using "other_crimes.tex", replace br label nocons nonotes  drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, -) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

foreach i of loc crime_vars {
	xtpqml `i' devbelow0 devabove0  dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 , fe cluster(id)
	qui summ `i' if devbelow0!=. & devabove0!=. 
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
	outreg2 using "other_crimes.tex", append br label nocons nonotes  drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, -) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

}


//Multiple Hypothesis Testing//
**Creating a dataset with the p-values of negative ground water shocks for the 6 regressions above//
/*
pval
  0
.414
.179
.525
.718
*/

use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\pvalue_negative_shock_table_A7.dta", replace

pause

quietly sum pval
local totalpvals = r(N)

* Sort the p-values in ascending order and generate a variable that codes each p-value's rank

quietly gen int original_sorting_order = _n
quietly sort pval
quietly gen int rank = _n if pval~=.

* Set the initial counter to 1 

local qval = 1

* Generate the variable that will contain the BH (1995) q-values

gen bh95_qval = 1 if pval~=.

* Set up a loop that begins by checking which hypotheses are rejected at q = 1.000, then checks which hypotheses are rejected at q = 0.999, then checks which hypotheses are rejected at q = 0.998, etc.  The loop ends by checking which hypotheses are rejected at q = 0.001.

while `qval' > 0 {
	* Generate value qr/M
	quietly gen fdr_temp = `qval'*rank/`totalpvals'
	* Generate binary variable checking condition p(r) <= qr/M
	quietly gen reject_temp = (fdr_temp>=pval) if fdr_temp~=.
	* Generate variable containing p-value ranks for all p-values that meet above condition
	quietly gen reject_rank = reject_temp*rank
	* Record the rank of the largest p-value that meets above condition
	quietly egen total_rejected = max(reject_rank)
	* A p-value has been rejected at level q if its rank is less than or equal to the rank of the max p-value that meets the above condition
	replace bh95_qval = `qval' if rank <= total_rejected & rank~=.
	* Reduce q by 0.001 and repeat loop
	quietly drop fdr_temp reject_temp reject_rank total_rejected
	local qval = `qval' - .001
}
	
quietly sort original_sorting_order


*****************************************************************************************************
* Table A8: Effect of Groundwater Depth Shocks on Violence not Related to Gender*
******************************************************************************************************


use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"
xtset id year
local crime_vars " total_kidnap_abduct total_robbery total_theft total_counterfeiting total_death_by_negligence "
xi:xtpqml total_murder devbelow0 devabove0  dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 ,fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=. 
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using "other_crimes2.tex", replace br label nocons nonotes  drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, -) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

foreach i of loc crime_vars {
	xtpqml `i' devbelow0 devabove0  dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 , fe cluster(id)
	qui summ `i' if devbelow0!=. & devabove0!=. 
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
	outreg2 using "other_crimes2.tex", append br label nocons nonotes  drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, -) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

}

//Multiple Hypothesis Testing//

**Creating a dataset with the p-values of negative ground water shocks for the 5 regressions above//
/*
.819
.689
.609
.033
.945
.443
*/

use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\pvalue_negative_shock_table_A8.dta", clear

q
pause

* Collect the total number of p-values tested

quietly sum pval
local totalpvals = r(N)

* Sort the p-values in ascending order and generate a variable that codes each p-value's rank

quietly gen int original_sorting_order = _n
quietly sort pval
quietly gen int rank = _n if pval~=.

* Set the initial counter to 1 

local qval = 1

* Generate the variable that will contain the BH (1995) q-values

gen bh95_qval = 1 if pval~=.

* Set up a loop that begins by checking which hypotheses are rejected at q = 1.000, then checks which hypotheses are rejected at q = 0.999, then checks which hypotheses are rejected at q = 0.998, etc.  The loop ends by checking which hypotheses are rejected at q = 0.001.

while `qval' > 0 {
	* Generate value qr/M
	quietly gen fdr_temp = `qval'*rank/`totalpvals'
	* Generate binary variable checking condition p(r) <= qr/M
	quietly gen reject_temp = (fdr_temp>=pval) if fdr_temp~=.
	* Generate variable containing p-value ranks for all p-values that meet above condition
	quietly gen reject_rank = reject_temp*rank
	* Record the rank of the largest p-value that meets above condition
	quietly egen total_rejected = max(reject_rank)
	* A p-value has been rejected at level q if its rank is less than or equal to the rank of the max p-value that meets the above condition
	replace bh95_qval = `qval' if rank <= total_rejected & rank~=.
	* Reduce q by 0.001 and repeat loop
	quietly drop fdr_temp reject_temp reject_rank total_rejected
	local qval = `qval' - .001
}
	
quietly sort original_sorting_order



**********************************************************************************************************
*******************Table A9: Effect of Groundwater Depth Shocks on Rape: NFHS sample***********************
**********************************************************************************************************


use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\rape_2015.dta", clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File"
merge m:m sdist year using groundwater.dta
keep if year==2015
drop _merge
drop if d125==.
gen rape=(d124==1)
gen rural=(v140==2)

merge m:m sdist using census_2011.dta
gen percent_sc= P_SC/ TOT_P
gen percent_st= P_ST/ TOT_P
gen percent_lit= P_LIT / TOT_P
gen percent_work= TOT_WORK_P / TOT_P
gen tot_p=TOT_P

drop _merge
merge m:m sdist year using precepitation_2015_census_code.dta


gen time_water= v115
replace time_water=0 if v115==996
replace time_water=. if v115>=997
gen wellwater= (v113==21| v113==31| v113==32)
destring udel_precep_ udel_temp, replace force
gen udel_missing=1 if udel_precep_==.
replace udel_precep_=0 if udel_precep_==.
replace udel_missing=0 if udel_missing ==.
gen report=(d128==1)


cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

//Rape: Reduced Form//

reg rape devbelow devabove0 
qui summ rape if year==2015
scalar mean=`r(mean)'

test (devbelow0=0) (devabove0=0)

outreg2 using "rape_reduced_form_2015.xls", replace br label drop(dumyr* int* total_* idcode_dum* outlier) addtext(Rainfall controls, No, Socioeconomic Controls, No) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)
reg rape devbelow devabove0  udel_precep_ udel_missing 
qui summ rape if year==2015
scalar mean=`r(mean)'

test (devbelow0=0) (devabove0=0)
outreg2 using "rape_reduced_form_2015.xls", append br label drop(dumyr* int* total_* idcode_dum* outlier) addtext(Rainfall controls, Yes, Socioeconomic Controls, No) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)
reg rape devbelow devabove0   udel_precep_ udel_missing i.year v136  v190 i.v131 v012 rural if year==2015
qui summ rape 
scalar mean=`r(mean)'

test (devbelow0=0) (devabove0=0)

outreg2 using "rape_reduced_form_2015.xls", append br label drop(dumyr* int* total_* idcode_dum* outlier) addtext(Rainfall controls, Yes, Socioeconomic Controls, Yes) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)




**********************************************************************************************************
*******************Table A10: Effect of Groundwater Depth Shocks on Reporting Pattern***********************
**********************************************************************************************************


use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\rape_2015.dta", clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File"
merge m:m sdist year using groundwater.dta
keep if year==2015
drop _merge
drop if d125==.
gen rape=(d124==1)
gen rural=(v140==2)

merge m:m sdist using census_2011.dta
gen percent_sc= P_SC/ TOT_P
gen percent_st= P_ST/ TOT_P
gen percent_lit= P_LIT / TOT_P
gen percent_work= TOT_WORK_P / TOT_P
gen tot_p=TOT_P

drop _merge
merge m:m sdist year using precepitation_2015_census_code.dta


gen time_water= v115
replace time_water=0 if v115==996
replace time_water=. if v115>=997
gen wellwater= (v113==21| v113==31| v113==32)
destring udel_precep_ udel_temp, replace force
gen udel_missing=1 if udel_precep_==.
replace udel_precep_=0 if udel_precep_==.
replace udel_missing=0 if udel_missing ==.
gen report=(d128==1)

cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"


reg report devbelow devabove0   if  rape==1, cluster(sdist)
qui summ report if  rape==1
scalar mean=`r(mean)'

test (devbelow0=0) (devabove0=0)

outreg2 using "report_reduced_form_2015.xls", replace br label drop(dumyr* int* total_* idcode_dum* outlier) addtext(Rainfall controls, No, Socioeconomic Controls, No) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

reg report devbelow devabove0  udel_precep_ udel_missing if  rape==1, cluster(sdist)
qui summ report if  rape==1
scalar mean=`r(mean)'

test (devbelow0=0) (devabove0=0)

outreg2 using "report_reduced_form_2015.xls", append br label drop(dumyr* int* total_* idcode_dum* outlier) addtext(Rainfall controls, No, Socioeconomic Controls, No) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

reg report devbelow devabove0   udel_precep_ udel_missing  v136  v190 i.v131 v012 rural if  rape==1, cluster(sdist)
qui summ report if rape==1
scalar mean=`r(mean)'

test (devbelow0=0) (devabove0=0)

outreg2 using "report_reduced_form_2015.xls", append br label drop(dumyr* int* total_* idcode_dum* outlier) addtext(Rainfall controls, No, Socioeconomic Controls, No) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)


*****************************************************************************************************
* Table A11: Effect of Groundwater Depth Shocks on Rape: Using Household Data*
******************************************************************************************************

use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\master_data_final.dta", clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"



collapse (first) lnrape rape devbelow0 devabove0 raindev1 raindevsq int_percent_sc_05-int_percent_sc_12 int_percent_lit_05-int_percent_lit_12 int_percent_work_05-int_percent_work_12 int_pop_05-int_pop_12 (mean) consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned, by(id year)
xtset id year

xi:xtpqml rape devbelow0 devabove0 i.year raindev1 raindevsq, cluster(id)
qui summ rape if devbelow0!=. & devabove0!=. 
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using "rape_hh.xls",replace br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)

xi:xtpqml rape  devbelow0 devabove0 i.year raindev1 raindevsq consumption_pc below_pov_line  motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu  ,   cluster(id)
qui summ rape if devbelow0!=. & devabove0!=. 
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using "rape_hh.xls", append br label nocons nonotes eq(auto) ctitle(" ") drop(consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, Yes, Other controls, HH attributes) addstat("F stat", `r(chi2)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)



 *****************************************************************************************************
* Table A12: Effect of Groundwater Depth Shocks on Rape by Urban and Rural Locations*
******************************************************************************************************
use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\master_data_final.dta", clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

gen rural=1 if URBAN4_2011>=2
replace rural=0 if URBAN4_2011<2
for var devabove0 devbelow0: gen X_rural=X*rural
areg lnrape devbelow0 devabove0 i.year raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned  if rural==1,absorb(id) cluster(id)
qui summ rape if devbelow0!=. & devabove0!=. & rural==1 
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using "rape_heterogeneity_rural.xls",replace br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)
areg lnrape devbelow0 devabove0 i.year raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned  if rural==0,absorb(id) cluster(id)
qui summ rape if devbelow0!=. & devabove0!=. & rural==0 
scalar mean=`r(mean)'
test (devbelow0=0) (devabove0=0)
outreg2 using "rape_heterogeneity_rural.xls",append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(F)', "Sig. level", `r(p)',"Mean of the dependent variable", mean)
//Chow Test//
reg lnrape devbelow0 devabove0 i.year raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned i.id if rural==1
estimate store rape_rural

reg lnrape devbelow0 devabove0 i.year raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned i.id if rural==0
estimate store rape_urban

suest rape_rural rape_urban
test [rape_rural_mean]devbelow0-[rape_urban_mean]devbelow0=0
*P-value=0.00

*****************************************************************************************************
* Table A13: Effect of Groundwater Depth Shocks on Rape by Source of Water*
******************************************************************************************************
use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\master_data_final.dta", clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

gen rural=1 if URBAN4_2011>=2
replace rural=0 if URBAN4_2011<2
areg lnrape devbelow0 devabove0 i.year raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned  if wellwater==1,absorb(id) cluster(id)
test (devbelow0=0) (devabove0=0)
outreg2 using "rape_heterogeneity_wellwater.xls",replace br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(F)', "Sig. level", `r(p)')

areg lnrape devbelow0 devabove0 i.year raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned  if wellwater==0,absorb(id) cluster(id)
test (devbelow0=0) (devabove0=0)
outreg2 using "rape_heterogeneity_wellwater.xls",append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(F)', "Sig. level", `r(p)')


reg lnrape devbelow0 devabove0 i.year raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned i.id if wellwater==1
estimate store rape_wellwater

reg lnrape devbelow0 devabove0 i.year raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned i.id if wellwater==0
estimate store rape_nowellwater

suest rape_wellwater rape_nowellwater
test [rape_wellwater_mean]devbelow0-[rape_nowellwater_mean]devbelow0=0





*****************************************************************************************************
* Table A14: Effect of Groundwater Shock on the Probability of Switching the Water Source or Water Collector*
******************************************************************************************************



use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\master_data_final.dta", clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

***Switching variable: water source********
gen l_wellwater=l7.wellwater
gen switch_wellwater=(wellwater==0 & l_wellwater==1)
*replace switch_wellwater=. if l_wellwater==0
reg switch_wellwater devbelow0 devabove0  i.year raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned l7.devbelow0 l7.devabove0 i.stateid  if year==2012 , cluster(id)
test (devbelow0=0) (devabove0=0)
outreg2 using "water_use_pattern.xls",replace br label drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(F)', "Sig. level", `r(p)')


***Switching variable: water collector********
drop switch
gen male_only=male if female==0
gen female_only=female if male==0
for var male_only female_only: replace X=0 if X==.
gen l_male_only=l7.male_only
gen l_female_only=l7.female_only
gen switch=(l_female_only==1 & male_only==1)
replace switch=0 if switch==.


reg switch devbelow0 devabove0 i.year raindev1 raindevsq consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned   if year==2012 , cluster(id)
test (devbelow0=0) (devabove0=0)
outreg2 using "water_use_pattern.xls",append br label drop(dumyr* int* total_* idcode_dum* outlier) addtext(Demographic controls, No, Other controls, -) addstat("F stat", `r(F)', "Sig. level", `r(p)')











*****************************************************************************************************
* Table A15 : Impact of Time to Collect Water on the Probability that a Female Fetches Water Conditionalon Wells as the Main Source of Water*
******************************************************************************************************

use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\master_data_final.dta", clear
cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"
areg  female walk_tm_water  i.year if wellwater==1, absorb(id) robust
qui summ female  if wellwater==1
scalar mean=`r(mean)'

outreg2 using "female.tex", replace br label nocons nonotes eq(auto) ctitle(" ") drop(raindev1 raindevsq ) addtext(Controls, no) addstat("Mean of the dependent variable", mean)
areg  female walk_tm_water consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_owned i.year if wellwater==1, absorb(id) robust
qui summ female  if wellwater==1
scalar mean=`r(mean)'
outreg2 using "female.tex", append br label nocons nonotes eq(auto) ctitle(" ") drop( consumption_pc below_pov_line kisan_credit motorcycle color_tv telephone mem_mahila_mandal member_union hh_electricity hh_members highest_adedu area_ownedraindev1 raindevsq ) addtext(Controls, yes) addstat("Mean of the dependent variable", mean)


*****************************************************************************************************
* Table A16: Effect of Groundwater Depth Shocks on Rape: By Water Infrastructure*
******************************************************************************************************

use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
cd  "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File" 

merge 1:1 id year using CapEx_WtrInfra_id_unbalance_MultDistProject.dta, keepusing(n_wtr_Infra)
sort id year
replace n_wtr_Infra=0 if n_wtr_Infra==.
for var devbelow0 devabove0:gen X_waterinfra=X* n_wtr_Infra


cd "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Results"

xi:xtpqml total_rape devbelow0 devabove0 dumyr* raindev1 raindevsq int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 n_wtr_Infra, fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=. 
scalar mean=`r(mean)'
outreg2 using "water_infrastructure.xls", replace br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addstat("Mean of the dependent variable", mean) 


xi:xtpqml total_rape devbelow0 devabove0 raindev1 raindevsq devbelow0_waterinfra devabove0_waterinfra dumyr* int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_percent_fm_ratio_03- int_percent_fm_ratio_07 int_pop_03-int_pop_07 n_wtr_Infra, fe cluster(id)
qui summ total_rape if devbelow0!=. & devabove0!=. 
scalar mean=`r(mean)'
outreg2 using "water_infrastructure.xls", append br label nocons nonotes eq(auto) ctitle(" ") drop(dumyr* int* total_* idcode_dum* outlier) addstat("Mean of the dependent variable", mean)


***********Creating the confidence Interval Using Delta method****************
use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\master_data_final.dta", clear
for var devbelow0 devabove0 id: gen X_ihds=X
areg  lnwalk_tm_water  devbelow0 devabove0  i.year, absorb(id_ihds) robust
estimates store model2
tempfile model2
save `model2'
use "C:\Users\Amzad\Dropbox\UVA Collaboration\Water_crime_Sheetal\Replication-JAERE-deidentified\Data and Do File\crime_water_data_2002_2007_final.dta" , clear
merge 1:1 _n using `model2'
reg lnrape devbelow0 devabove0 dumyr* int_percent_sc_03-int_percent_sc_07 int_percent_lit_03-int_percent_lit_07 int_percent_work_03-int_percent_work_07 int_pop_03-int_pop_07 i.id
estimates store model1
reg  lnwalk_tm_water  devbelow0_ihds devabove0_ihds  i.round i.id_ihds
estimates store model2
suest model1 model2, robust
nlcom (_b[model1_mean:devbelow0] / ( _b[model2_mean:devbelow0_ihds]*2*5.14))
nlcom ((9.58* _b[model1_mean:devbelow0]) / ( _b[model2_mean:devbelow0_ihds]*2*5.14))

